import Global from "../../../Global"
import cjs=createjs
import SignInDay from "./SignInDay"
import LocalData from "../../../LocalData"
//import createjs from "../../../../createjs"
export default class SevenDays extends cjs.Container{
    private _bg:cjs.ScaleBitmap
    private dayList:SignInDay[]=[]
    private _w=700
    private _h=800
    constructor(){
        super()
        //背景
        this._bg=new cjs.ScaleBitmap(Global.loader.getResource('signin_bg') as HTMLImageElement,new cjs.Rectangle(100,100,40,40))
        this._bg.setDrawSize(this._w,this._h)
        //this._bg.setTransform(0,100,1,1,0,0,0,this._w/2,this._h/2)
        this.addChild(this._bg)
        //
        const startx=60,starty=80,list=Global.loader.getResult('config').sign
        for(let i=0;i<7;i++){
            const coin=list[i].gold_coin
            const day=new SignInDay()
            day.setTransform(startx+i%3*188,starty+Math.floor(i/3)*270)
            day.setDayIndex(i)
            this.addChild(day)
            this.dayList.push(day)
            day.setRewardCoin(coin)
            console.log(i,LocalData.getInstance().signday)
            if(i>LocalData.getInstance().signday){

                day.alpha=0.7
            }else{
                day.alpha=1
            }
        }
        const day=this.dayList[6]
        const rect=day.getBounds()
        day.x=(600-rect.width*0.8)/2
        
    }
    getBounds(): cjs.Rectangle {
        return new cjs.Rectangle(0,0,this._w,this._h)
    }
    setSize(w:number,h:number):void{
        this._w=w
        this._h=h
        this._bg.setDrawSize(this._w,this._h)
    }
}